<?php

namespace App\common\Plugins\ThirdPartyLogin\Listeners;


use App\common\Plugins\ThirdPartyLogin\Controllers\InitController;
use App\common\Interfaces\ListenterPlugins;

class ThirdPartyLogin implements ListenterPlugins {
    /**
     * 事件.
     */
    public function callBack($event) {
        //支付
        if ($event->req_type == "getCode") {
            if ($event->login_method == "WeChat") {
                //微信code
                return InitController::weChatCode($event);
            } elseif ($event->login_method == "Alipay") {
                //支付宝code

            }
        } elseif ($event->req_type == "codeGetInfo") {
            if ($event->login_method == "WeChat") {
                //微信code
                return InitController::codeGetWeChatInfo($event);
            } elseif ($event->login_method == "Alipay") {
                //支付宝code
            }
        } elseif ($event->req_type == "publicTokenGetWeChatUserInfo") {
            if ($event->login_method == "WeChat") {
                //微信code
                return InitController::publicTokenGetWeChatUserInfo($event);
            } elseif ($event->login_method == "Alipay") {
                //支付宝code
            }
        } elseif ($event->req_type == "share") {
            if ($event->login_method == "WeChat") {
                //微信code
                return InitController::share($event);
            } elseif ($event->login_method == "Alipay") {
                //支付宝code
            }
        } else {
            //throw new \Exception("drive有误！",40000);
            // 事件会所有执行，所以不能打回错误
        }
    }
}
